package com.rc.evcharger.common.utils.log;

import java.io.*;

/**
 * 筛选日志
 * 2017年12月22日
 * @author peter
 */
public class SelOrderNumUtil {
	/**
	 * 默认存放路径
	 */
	public static final String filePah="E:\\selReport.txt";
	/**
	 * 筛选指定的字符串行放入E:\\123.TXT文件夹中
	 * @param fileName
	 *            文件路径+日志名;
	 * @param orderNum
	 *            需要查询的字符串;
	 */
	public static void getSelReport(String fileName, String orderNum) {
		BufferedWriter writer = null;
		BufferedReader reader = null;
		String temp = null;
		new File(filePah);
		int line = 1;
		try {
			writer = new BufferedWriter(new FileWriter(filePah,true));
			reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
			while ((temp = reader.readLine()) != null) {
				if (temp.indexOf(orderNum) != -1) {
					System.out.println(line + ":" + temp+"\n" );
					writer.write(line + ":" + temp + "\r\n\r\n");
					line++;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	public static void main(String[] args) {                         //004401191118122121190079313865
		//getSelReport("E:\\testWord\\25\\jinzhuang_server_command.log.23", "01 03 07 01 00 02 00 01 02 01 06");
		//getSelReport("C:\\Users\\Administrator\\Desktop\\123.log", "19 00 82 81");

		String aa= "AA F5 98 00 10 00 69 00 00 00 00 00 94 A9 16 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D";
		String newbb= "aa f5 98 00 10 00 69 00 00 00 00 00 e6 5b e3 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c9";

		System.out.println(aa.split(" ").length);
		System.out.println(newbb.split(" ").length);
	}
}
